// pages/mingxi/mingxi.js
var app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    //内容
    wendaArr1: [
    ],
    wendaArr: [],
    index: "",
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    var bgc = wx.getStorageSync('color')
    wx.setNavigationBarColor({
      frontColor: "#ffffff",
      backgroundColor: bgc,
    })
    var that = this
    
    app.util.request({
      'url': 'entry/wxapp/Selmypay',
      data: {
        use_openid: wx.getStorageSync('openid')
      },
      success: function (res) {
        console.log(res)
        var wendaArr = that.data.wendaArr
        var wendaArr1 = res.data.data.countmoney
        wendaArr = Array.from(wendaArr1)
        that.setData({
          wendaArr: wendaArr,
          wendaArr1: wendaArr1
        })
      }
    })
  },
  bindMultiPickerChange: function(e) {
    console.log('picker发送选择改变，携带值为', e.detail.value)
    var that = this
    var wendaArr = []
    var wendaArr1 = that.data.wendaArr1
    var wendaArr2 = []
    wendaArr2 = Array.from(wendaArr1)
    var multiArray = that.data.array
    // if (e.detail.value[0] != 1) {
      for (var i = 0, len = wendaArr2.length; i < len; i++) {
        console.log(wendaArr2[i].leixing, multiArray[e.detail.value])
        if (wendaArr2[i].leixing == multiArray[e.detail.value]) {
          wendaArr.push(wendaArr2[i])
        }
      }
      that.setData({
        wendaArr: wendaArr
      })
    // } else {
    //   for (var i = 0, len = wendaArr2.length; i < len; i++) {
    //     console.log(wendaArr2[i].leixing, multiArray[e.detail.value[0]])
    //     if (wendaArr2[i].leixing == multiArray[1][e.detail.value[1]]) {
    //       wendaArr.push(wendaArr2[i])
    //     }
    //   }
    //   that.setData({
    //     wendaArr: wendaArr
    //   })
    // }
    this.setData({
      multiIndex: e.detail.value
    })
  },

  input: function(e) {
    var that = this
    console.log(e)
    var values = e.detail.value
    var wendaArr = []
    var wendaArr1 = that.data.wendaArr1
    var wendaArr2 = []
    wendaArr2 = Array.from(wendaArr1)
    for (var i = 0, len = wendaArr2.length; i < len; i++) {
      if (wendaArr2[i].leixing.indexOf(values) != -1) {
        wendaArr.push(wendaArr2[i])
      }
    }
    that.setData({
      wendaArr: wendaArr
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function() {

  },
  //查询我的所有消费

})